/*
 * @lc app=leetcode.cn id=345 lang=cpp
 *
 * [345] 反转字符串中的元音字母
 */
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <unordered_set>

using namespace std;
// @lc code=start
class Solution {
public:
    string reverseVowels(string s) {
        unordered_set<char> set = {'a','A','e','E','i','I','o','O','u','U'};
        int left = 0,right = s.size()-1;
        while(left < right) {
            if(!set.count(s[left])) {
                left++;
            }
            if(!set.count(s[right])) {
                right--;
            }
            if(set.count(s[left]) && set.count(s[right])) {
                swap(s[left],s[right]);
                left++;
                right--;
            }
        }
        return s;
    }
};
// @lc code=end

